/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cl.bussines.entities;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Vogel
 */
@Entity
@Table(name = "productos_prov")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "ProductosProv.findAll", query = "SELECT p FROM ProductosProv p"),
    @NamedQuery(name = "ProductosProv.findByIdProdProv", query = "SELECT p FROM ProductosProv p WHERE p.idProdProv = :idProdProv"),
    @NamedQuery(name = "ProductosProv.findByCodProdProv", query = "SELECT p FROM ProductosProv p WHERE p.codProdProv = :codProdProv"),
    @NamedQuery(name = "ProductosProv.findByDescripcion", query = "SELECT p FROM ProductosProv p WHERE p.descripcion = :descripcion")})
public class ProductosProv implements Serializable {
    private static final long serialVersionUID = 1L;
    @Basic(optional = false)
    @Column(name = "id_Prod_Prov")
    private int idProdProv;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 30)
    @Column(name = "Cod_Prod_Prov")
    private String codProdProv;
    @Size(max = 60)
    @Column(name = "Descripcion")
    private String descripcion;
    @JoinColumn(name = "id_Marca", referencedColumnName = "id_Marca")
    @ManyToOne
    private Marcas idMarca;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "codProdProv")
    private Collection<DetalleOrden> detalleOrdenCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "codProdProv")
    private Collection<ProvHasProd> provHasProdCollection;

    public ProductosProv() {
    }

    public ProductosProv(String codProdProv) {
        this.codProdProv = codProdProv;
    }

    public ProductosProv(String codProdProv, int idProdProv) {
        this.codProdProv = codProdProv;
        this.idProdProv = idProdProv;
    }

    public int getIdProdProv() {
        return idProdProv;
    }

    public void setIdProdProv(int idProdProv) {
        this.idProdProv = idProdProv;
    }

    public String getCodProdProv() {
        return codProdProv;
    }

    public void setCodProdProv(String codProdProv) {
        this.codProdProv = codProdProv;
    }

    public String getDescripcion() {
        return descripcion;
    }

    public void setDescripcion(String descripcion) {
        this.descripcion = descripcion;
    }

    public Marcas getIdMarca() {
        return idMarca;
    }

    public void setIdMarca(Marcas idMarca) {
        this.idMarca = idMarca;
    }

    @XmlTransient
    public Collection<DetalleOrden> getDetalleOrdenCollection() {
        return detalleOrdenCollection;
    }

    public void setDetalleOrdenCollection(Collection<DetalleOrden> detalleOrdenCollection) {
        this.detalleOrdenCollection = detalleOrdenCollection;
    }

    @XmlTransient
    public Collection<ProvHasProd> getProvHasProdCollection() {
        return provHasProdCollection;
    }

    public void setProvHasProdCollection(Collection<ProvHasProd> provHasProdCollection) {
        this.provHasProdCollection = provHasProdCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (codProdProv != null ? codProdProv.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ProductosProv)) {
            return false;
        }
        ProductosProv other = (ProductosProv) object;
        if ((this.codProdProv == null && other.codProdProv != null) || (this.codProdProv != null && !this.codProdProv.equals(other.codProdProv))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "cl.bussines.entities.ProductosProv[ codProdProv=" + codProdProv + " ]";
    }
    
}
